import { request } from "../request";

export interface QuestionDetail {
    questionId: number;
    creatorId: number;
    content: string;
    options: Record<string, unknown>;
    answer: string;
    difficulty: string;
    createdAt: Record<string, unknown>;
    type: number;
}

export interface GetQuestionByQuestionIdRes {
    code: number;
    message: string;
    data: QuestionDetail;
    timestamp: Record<string, unknown>;
}

const getQuestionByQuestionIdAPI = async (questionId: number): Promise<GetQuestionByQuestionIdRes> => {
    const token = localStorage.getItem("token");
    return request(`/api/questions/${questionId}`, {
        method: "get",
        headers: {
            "Content-Type": "application/json",
            "Authorization": `Bearer ${token}`,
        },
    });
};

export default getQuestionByQuestionIdAPI;
